﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using SimilarWordsService;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void submitButton_Click(object sender, EventArgs e)
    {
        //Get the text from the input text box.
        string input = similarWordTextBox.Text.Trim();
        //Validate the input. We don't want digits or special characters.
        var regexItem = new Regex("^[a-zA-Z]*$");
        if (regexItem.IsMatch(input))
        {
            SimilarWordsWCFServiceClient client =
    new SimilarWordsWCFServiceClient();
            string[] similarWords = client.SimilarWords(input);
            client.Close();
            similarWordsLabel.Text = String.Join(", ", similarWords);
        }
        else
        {
            similarWordsLabel.Text = "Input must be only alphanumeric characters.";
        }
    }
}